#!/usr/bin/python
"""
Rename a movie.
"""

import sys

from movie.vote.models import Movie

def RenameMovie(old, new):
  m = Movie.objects.get(pk=old)
  voters = list(m.voters.all())
  downvoters = list(m.downvoters.all())
  m.name = new
  m.save()
  for voter in voters:
    m.voters.add(voter)
  for downvoter in downvoters:
    m.downvoters.add(downvoter)

  m = Movie.objects.get(pk=old)
  m.delete()
  

if __name__ == '__main__':
  RenameMovie(sys.argv[1], sys.argv[2])
